<!DOCTYPE HTML>
<html>

<head>
    <title>运费模版管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../../../assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
    <link href="../../../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="../../../assets/css/page-min.css" rel="stylesheet" type="text/css" />
    <link href="../../../assets/css/jx-style.css" rel="stylesheet" type="text/css">    <link href="../../../assets/css/prettify.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div class="container">
        <div class="detail-page">
            <div class=" ">
                <h3>运费模版管理<button type="button" id="add-freight-btn" class="pull-right button button-default">添加运费模版</button></h3>
                <hr>
            </div>
            <div class="detail-section">
                <div class=" detail-row">
                    <div class=" ">
                        <!-- 表格 start-->
                        <div id="grid"></div>
                        <!-- 表格 end-->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 初始隐藏 dialog内容 -->
    <div id="content" class="hide">
        <form class="form-horizontal">
            <div class="row">
                <div class="control-group span12">
                    <label class="control-label">
                        户名</label>
                    <div class="controls">
                        <span class="control-text">上海激想体育文化股份有限公司</span>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span12">
                    <label class="control-label">
                        <s>*</s>
                        账户名称：</label>
                    <div class="controls">
                        <input type="text" data-rules="{required : true}" class="control-text" name="a">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span12">
                    <label class="control-label">
                        <s>*</s> 卡号：</label>
                    <div class="controls">
                        <input type="text" data-rules="{required : true}" class="control-text" name="b">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span12">
                    <label class="control-label">
                        <s>*</s> 开户行：</label>
                    <div class="controls">
                        <input type="text" data-rules="{required : true}" class="control-text" name="c">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript" src="../../../assets/js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="../../../assets/js/bui-min.js"></script>
    <script type="text/javascript" src="../../../assets/js/config-min.js"></script>
    <script type="text/javascript">
    BUI.use('common/page');
    </script>
    <!-- script start -->
    <script type="text/javascript">
    $("#add-freight-btn").click(function() {
        top.topManager.openPage({
            id: 'add-freight-template',
            href: 'templates/system-settings/freight-template/add-freight-template.html',
            title: '添加运费模板'
        });
    });
    BUI.use(['bui/grid', 'bui/data', 'common/search'], function(Grid, Data, Search) {
        var Grid = Grid,
            enumObj = {
                "1": "待发货",
                "2": "已发货"
            },
            Store = Data.Store,
            columns = [{
                title: '模版名称',
                dataIndex: 'a',
                elCls: 'center', //居中
                width: 200,
            }, {
                title: '最后编辑时间',
                elCls: 'center',
                dataIndex: 'b',
                width: 200
            }, {
                title: '配送方式',
                elCls: 'center',
                dataIndex: 'c',
                width: 200,

            }, {
                title: '目的地',
                elCls: 'center',
                dataIndex: 'd',
                width: 200,

            }, {
                title: '商品总额满（ 元）',
                elCls: 'center',
                dataIndex: 'e',
                width: 200,

            }, {
                title: '运费(批量下单 元 / 件)',
                elCls: 'center',
                dataIndex: 'f',
                width: 200,

            }, {
                title: '运费(分销下单 元 / 单)',
                elCls: 'center',
                dataIndex: 'g',
                width: 200,

            }, {
                title: '状态',
                elCls: 'center',
                dataIndex: 'h',
                width: 200,

            }, {
                title: '操作',
                dataIndex: 'f',
                elCls: 'center',
                width: 200,
                renderer: function(value, obj) {
                    var editStr = Search.createLink({ //链接使用 此方式
                            id: 'edit' + obj.id,
                            title: '添加运费模板',
                            text: '[ 编辑 ] ',
                            href: 'templates/system-settings/freight-template/add-freight-template.html'
                        }),
                        delStr = '<span class="grid-command btn-del">[ 删除 ]</span>'; //页面操作不需要使用Search.createLink
                    return editStr + delStr;
                }
            }],
            data = [{
                a: '模版1',
                b: '2016-08-18 15:18',
                c: '快递',
                d: '全国 ',
                e: '1.00',
                f: '1.00',
                g: '10.00',
                h: '默认'
            }, {
                a: '模版1',
                b: '2016-08-18 15:18',
                c: '快递',
                d: '全国 ',
                e: '1.00',
                f: '1.00',
                g: '10.00',
                h: '默认'
            }];
        //初始化数据
        var isAddRemote = false,
            editing = new Grid.Plugins.DialogEditing({
                contentId: 'content', //设置隐藏的Dialog内容
                triggerCls: 'btn-edit', //触发显示Dialog的样式
                editor: {
                    title: '添加转账信息'
                }

            }),
            store = new Store({ //初始化数据
                data: data,
                autoLoad: true, //自动加载数据
                pageSize: 2 // 配置分页数目
            }),
            grid = new Grid.Grid({
                render: '#grid',
                elCls: 'small-bui-grid-table',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                forceFit: true,
                // 底部工具栏
                bbar: {
                    // pagingBar:表明包含分页栏
                    pagingBar: true
                },
                plugins: [editing], //插件
                store: store
            });

        grid.render();
        //点击操作
        grid.on('itemclick', function(ev) {
            var sender = $(ev.domTarget),
                itemEl = $(ev.element),
                item = ev.item;

            if (sender.hasClass('btn-del')) { //点击删除操作
                delFunction(item, itemEl);

            }

        });


        //没有多选插件，删除选中的记录
        function delFunction(item, itemEl) {
            BUI.Message.Confirm('确认删除记录？', function() {
                var input = itemEl.find('input'),
                    name = itemEl.attr('name');
                if (name) {
                    form.getField(name).remove();
                }

                store.remove(item);
            }, 'question');
        }


    });
    </script>
    <!-- script end -->

    <body>

</html>
